package com.sys.basics.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ArrayUtils {

    public static <E> HashMap<String, Object> arrayCompare(List<E> primaryList, List<E> secondaryList) {
        HashMap<String, Object> hashMap = new HashMap<>();
        List<E> missing = new ArrayList<E>();
        List<E> excess = new ArrayList<E>();

        for (E item : primaryList) {
            boolean contains = secondaryList.contains(item);
            if (!contains) missing.add(item);
        }

        for (E item : secondaryList) {
            boolean contains = primaryList.contains(item);
            if (!contains) excess.add(item);
        }
        hashMap.put("missing", missing);
        hashMap.put("excess", excess);
        System.out.println(hashMap);
        return hashMap;
    }
}
